/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package xcore.model.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import xcore.model.Model;
import xcore.model.ModelPackage;
import xcore.model.XAttribute;
import xcore.model.XClass;
import xcore.model.XReference;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link xcore.model.impl.ModelImpl#getXClasses <em>XClasses</em>}</li>
 *   <li>{@link xcore.model.impl.ModelImpl#getXAttributes <em>XAttributes</em>}</li>
 *   <li>{@link xcore.model.impl.ModelImpl#getXReferences <em>XReferences</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ModelImpl extends EObjectImpl implements Model {
	/**
	 * The cached value of the '{@link #getXClasses() <em>XClasses</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXClasses()
	 * @generated
	 * @ordered
	 */
	protected EList<XClass> xClasses;

	/**
	 * The cached value of the '{@link #getXAttributes() <em>XAttributes</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXAttributes()
	 * @generated
	 * @ordered
	 */
	protected EList<XAttribute> xAttributes;

	/**
	 * The cached value of the '{@link #getXReferences() <em>XReferences</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXReferences()
	 * @generated
	 * @ordered
	 */
	protected EList<XReference> xReferences;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ModelImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ModelPackage.Literals.MODEL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<XClass> getXClasses() {
		if (xClasses == null) {
			xClasses = new EObjectContainmentEList<XClass>(XClass.class, this, ModelPackage.MODEL__XCLASSES);
		}
		return xClasses;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<XAttribute> getXAttributes() {
		if (xAttributes == null) {
			xAttributes = new EObjectContainmentEList<XAttribute>(XAttribute.class, this, ModelPackage.MODEL__XATTRIBUTES);
		}
		return xAttributes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<XReference> getXReferences() {
		if (xReferences == null) {
			xReferences = new EObjectContainmentEList<XReference>(XReference.class, this, ModelPackage.MODEL__XREFERENCES);
		}
		return xReferences;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.MODEL__XCLASSES:
				return ((InternalEList<?>)getXClasses()).basicRemove(otherEnd, msgs);
			case ModelPackage.MODEL__XATTRIBUTES:
				return ((InternalEList<?>)getXAttributes()).basicRemove(otherEnd, msgs);
			case ModelPackage.MODEL__XREFERENCES:
				return ((InternalEList<?>)getXReferences()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ModelPackage.MODEL__XCLASSES:
				return getXClasses();
			case ModelPackage.MODEL__XATTRIBUTES:
				return getXAttributes();
			case ModelPackage.MODEL__XREFERENCES:
				return getXReferences();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ModelPackage.MODEL__XCLASSES:
				getXClasses().clear();
				getXClasses().addAll((Collection<? extends XClass>)newValue);
				return;
			case ModelPackage.MODEL__XATTRIBUTES:
				getXAttributes().clear();
				getXAttributes().addAll((Collection<? extends XAttribute>)newValue);
				return;
			case ModelPackage.MODEL__XREFERENCES:
				getXReferences().clear();
				getXReferences().addAll((Collection<? extends XReference>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ModelPackage.MODEL__XCLASSES:
				getXClasses().clear();
				return;
			case ModelPackage.MODEL__XATTRIBUTES:
				getXAttributes().clear();
				return;
			case ModelPackage.MODEL__XREFERENCES:
				getXReferences().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ModelPackage.MODEL__XCLASSES:
				return xClasses != null && !xClasses.isEmpty();
			case ModelPackage.MODEL__XATTRIBUTES:
				return xAttributes != null && !xAttributes.isEmpty();
			case ModelPackage.MODEL__XREFERENCES:
				return xReferences != null && !xReferences.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //ModelImpl
